#pragma once

#include <libmemcached/memcached.h>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <unistd.h>

class ESMemcache
{
public:
	ESMemcache(void);
	~ESMemcache(void);
public:
	bool Init(char* pIPPort, int msec=1000);
	bool SetRecord(char* key, const char* value, const size_t bytes, const time_t expire = 0);
	bool Replace(char* key, const char* value, const size_t bytes, const time_t expire = 0);
	void GetRecord(const char* key, std::string &value);
	bool DeleteRecord(const char* key);
	bool Increment(const char *key, int offset, uint64_t &value);
	bool Decrement(const char *key, int offset, uint64_t &value);
	bool IsKeyExist(const char *key);
private:
	int setTimeOut(int msec);
	memcached_return rc;
	memcached_st *memc;

};

